/*
 * Stats.cpp
 *
 *  Created on: Oct 8, 2011
 *  Created by: Devin Manno
 *  Updated by: Devin Manno,
 *	Last Update: Oct 14, 2011
 */
#include "Stats.h"

Stats::Stats(){
    agility = 1;            // affects character's ability to dodge attacks
    strength = 1;           // warrior's highest weighted attack damage stat
    intelligence = 1;       // wizard's highest weighted attack damage stat
    concentration = 1;      // ranger's highest weighted attack damage stat
    maxHitPoints = 100;     // max hit points, default 100
    maxActionPoints = 100;  // max action points, default 100
    damage = 0;				// damage of character, but can also be damage of weapon
    armor = 0;				// armor of character or armor pieces
}

Stats::Stats(int agil, int str, int intel, int conc, int maxAP, int maxHP, int dmg, int arm) {
	agility = agil;			// affects character's ability to dodge attacks
	strength = str;			// warrior's highest weighted attack damage stat
	intelligence = intel;	// wizard's highest weighted attack damage stat
	concentration = conc;	// ranger's highest weighted attack damage stat
	maxHitPoints = maxHP;	// default 100
	maxActionPoints = maxAP;// max action points
	damage = dmg;
	armor = arm;
}

Stats::~Stats() {
	// TODO Auto-generated destructor stub
}

// Getters
int Stats::getAgility() const{
	return agility;
}

int Stats::getStrength()const{
	return strength;
}

int Stats::getIntelligence() const{
	return intelligence;
}

int Stats::getConcentration() const{
	return concentration;
}

int Stats::getMaxActionPoints()const{
	return maxActionPoints;
}

int Stats::getMaxHitPoints()const{
	return maxHitPoints;
}

int Stats::getDamage()const{
	return damage;
}

int Stats::getArmor()const{
	return armor;
}

//Setters
void Stats::setStats(int agil, int str, int intel, int conc, int maxAP, int maxHP, int dmg, int arm){
	agility = agil;		// affects character's ability to dodge attacks
	strength = str;		// warrior's highest weighted attack damage stat
	intelligence = intel;	// wizard's highest weighted attack damage stat
	concentration = conc;	// ranger's highest weighted attack damage stat
	maxHitPoints = maxHP;	// default 100
	maxActionPoints = maxAP;	// max action points
	damage = dmg;
	armor = arm;
}

void Stats::setAgility(int agil){
	agility = agil;
}

void Stats::setStrength(int stren){
	strength = stren;
}

void Stats::setIntelligence(int intel){
	intelligence = intel;
}

void Stats::setConcentration(int concen){
	concentration = concen;
}

void Stats::setMaxActionPoints(int max){
	maxActionPoints = max;
}

void Stats::setMaxHitPoints(int max){
	maxHitPoints = max;
}

void Stats::setDamage(int dmg){
	damage = dmg;
}

void Stats::setArmor(int arm){
	armor = arm;
}

void Stats::loadStats(istream& in)
{
    char *tk = NULL;// pointers to chars
    char data[MAX] = ""; //to hold line
    in.getline(data,MAX - 1, '\n');
    tk = strtok(data, DELIMS); // get next token
    agility = atoi(tk);
    tk = strtok(NULL, DELIMS); // get next token
    strength = atoi(tk);
    tk = strtok(NULL, DELIMS); // get next token
    intelligence = atoi(tk);
    tk = strtok(NULL, DELIMS); // get next token
    concentration = atoi(tk);
    tk = strtok(NULL, DELIMS); // get next token
    maxActionPoints = atoi(tk);
    tk = strtok(NULL, DELIMS); // get next token
    maxHitPoints = atoi(tk);
    tk = strtok(NULL, DELIMS); // get next token
    damage = atoi(tk);
    tk = strtok(NULL, DELIMS); // get next token
    armor = atoi(tk);
}

void Stats::saveStats(ostream& out)
{
    out << agility << ',' << strength << ',' << intelligence << ',' << concentration << ','
        << maxActionPoints << ',' << maxHitPoints << ',' << damage << ',' << armor;
}
